<p class="Paragraph">Use the <span class="T1">GoTo</span> statement to instruct <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic to continue program execution at another place within the procedure. The position must be indicated by a label. To set a label, assign a name and end it with a colon (":").</p>
<p class="TextInTable"><span class="T1">GoTo</span> is a relict of BASIC dialects which is retained only for compatibility reasons. If you often use GoTo, your program will tend to become unreadable. For this reason, it is preferable to use Sub procedures, with exception of <span class="T1">On...GoTo</span> and <span class="T1">On Error GoTo</span>.</p>
</span></th></tr></table>
<p class="Paragraph"/>
<p class="P2">Example:</p>
<p class="PropText">Sub ExampleOnGosub</p>
<p class="PropText">Dim iVar As Integer</p>
<p class="PropText">Dim sVar As String</p>
<p class="PropText">iVar = 2</p>
<p class="PropText">sVar =""</p>
<p class="PropText">On iVar GoSub Sub1, Sub2</p>
<p class="PropText">On iVar GoTo Line1, Line2</p>
<p class="PropText">Exit Sub</p>
<p class="PropText">Sub1:</p>
<p class="PropText">sVar =sVar & <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>" From Sub 1 to" : Return</p>
<p class="PropText">Sub2:</p>
<p class="PropText">sVar =sVar & <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>" From Sub 2 to" : Return</p>